Engine.GameObject = function(){
    this.transform = new Engine.Transform();
    this.triangles = [];
    this.shader = new Engine.Shader();
    this.name = "gameObject";
}

Engine.GameObject.prototype = (function(){

    return {
        addTriangle: function(triangle){
            this.triangles.push(triangle);
        },
        center : function(){
            var c = new Engine.Vector3(0,0,0);
            for(var i = 0;i<this.triangles.length;i++){
                c = c.plus(this.triangles[i].center());
            }
            c = c.divide(this.triangles.length);
            return c;
        },
        begin : function(width,height,camera,staticScene){
            if(staticScene == undefined || !staticScene)
                this.shader.cubeTexture = undefined;
            this.m2c = camera.w2c().multiply(this.transform.m2w());

        	this.m2s =  new Engine.Matrix4x4();
        	this.m2s.m00 = width/2;
        	this.m2s.m03 = width/2;
        	this.m2s.m11 = -height/2;
        	this.m2s.m13 = height/2;
        	this.m2s.m22 = Engine.MaxZ/camera.d();
        	this.m2s.m33 = 1;

        	this.m2s = this.m2s.multiply(camera.c2p());
        	this.m2s = this.m2s.multiply(this.m2c);

            this.m2cn = this.m2c.clone();
        	this.m2cn.m03 = 0;
        	this.m2cn.m13 = 0;
        	this.m2cn.m23 = 0;
        }
    };
})();